package com.jhy.suixianglu.daima20230117;

/**
 * 移动匹配
 */
public class RepeatedSubstringPattern2 {
    public static boolean repeatedSubstringPattern(String s) {
        // 将原先字符串在重复拼接在后面
        StringBuilder append = new StringBuilder(s).append(s);
        // 去掉头和尾
        String substring = append.substring(1, append.length() - 1);
        return substring.contains(s);
    }

    public static void main(String[] args) {
        boolean hello = repeatedSubstringPattern("abab");
        System.out.println(hello);
    }
}
